import request from '@/apis/request';
import { GENERAL_REMOTE_OPTIONS } from '@/constants';
// 根据下拉框类型和项目所属获取下拉框数据
const findBySelectNameDefaultUrl = '/child/CommonDropoptionControl/findBySelectNameDefault';
// 各列表接口路径
const welfareorgsGetWelfareOrgsList = '/child/welfareorgs/getWelfareOrgsList';
const newChildEvaluatesGetReportList = '/child/newChildEvaluates/getReportList';

// login 登录接口
export const doLoginApi = (data?: object) => {
    return request(
        {
            url: '/child/child/login/doLogin',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 根据下拉框类型和项目所属获取下拉框数据
export const getUploadImageApi = (
    url?: string,
    data?: object,
    isLoading: boolean = false,
    isShowErrToast: boolean = true
) => {
    return request(
        {
            url,
            method: 'post',
            data,
        },
        isLoading,
        isShowErrToast
    );
};
// 行政区划
export const getCityOptionApi = (data?: object) => {
    return request(
        {
            url: '/child/childCity/getChildCityList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// excel公共导出

export const customizeExportApi = (data?: object, url?: string) => {
    return request(
        {
            // url: '/child/childExcelExport' + url + '/customizeExport',
            url: url + '/customizeExport',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 福利机构列表导出
export const welfareorgsGetWelfareOrgsListCustomizeExportApi = (data?: object) => {
    return customizeExportApi(data, welfareorgsGetWelfareOrgsList);
};
// 风险等级列表导出
export const newChildEvaluatesGetReportListCustomizeExportApi = (data?: object) => {
    return customizeExportApi(data, newChildEvaluatesGetReportList);
};

// 默认的字典查询
export const findBySelectNameDefaultApi = (data?: object) => {
    return request(
        {
            url: findBySelectNameDefaultUrl,
            method: 'post',
            data,
        },
        false,
        true
    );
};
// let findBySelectNameDefaultApis = new Array(GENERAL_REMOTE_OPTIONS.length);
// for (let i = 0; i < GENERAL_REMOTE_OPTIONS.length; i++) {
//     findBySelectNameDefaultApis[i] = (data?: object) => {
//         return request({
//             url: findBySelectNameDefaultUrl,
//             method: 'post',
//             data: {
//                 name: GENERAL_REMOTE_OPTIONS[i].name
//             }
//         },false, true);
//     }
// }
// export const findBySelectNameDefault0Api = findBySelectNameDefaultApis[0]
// export const findBySelectNameDefault1Api = findBySelectNameDefaultApis[1]

// 福利机构
// 福利机构列表
export const welfareorgsGetWelfareOrgsListApi = (data?: object) => {
    return request(
        {
            url: welfareorgsGetWelfareOrgsList,
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 查看福利机构信息
export const welfareorgsGetWelfareOrgsInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/welfareorgs/getWelfareOrgsInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 新增更新福利机构
export const welfareorgsAddChildInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/welfareorgs/addChildInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 机构儿童
// 机构儿童列表
export const welfareorgsGetOrphansListApi = (data?: object) => {
    return request(
        {
            url: '/child/welfareorgs/getOrphansList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 机构儿童信息
export const welfareorgsGetOrphansDetailApi = (data?: object) => {
    return request(
        {
            url: '/child/welfareorgs/getOrphansDetail',
            method: 'post',
            data,
        },
        false,
        true
    );
};

// 四色评估
// 风险等级列表
export const newChildEvaluatesGetReportListApi = (data?: object) => {
    return request(
        {
            url: newChildEvaluatesGetReportList,
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 风险等级查看评估报告打印
export const childEvaluateGetReportPdfApi = (data?: object) => {
    return request(
        {
            url: '/social/childEvaluate/getReportPdf',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 流动儿童
// 流动儿童对象管理列表
export const flowChildGetFlowChildListApi = (data?: object) => {
    return request(
        {
            url: '/child/flowChild/getFlowChildList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 流动儿童注销流动儿童信息
export const flowChildDeleteFlowChildInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/flowChild/deleteFlowChildInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 流动儿童查看流动儿童信息
export const flowChildGetFlowChildInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/flowChild/getFlowChildInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 流动儿童保存更新流动儿童信息
export const flowChildSaveFlowChildInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/flowChild/saveFlowChildInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};

// 留守儿童
// 留守儿童注销留守儿童信息
export const leftBehindChildrenDeleteLeftBehindChildrenInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/leftBehindChildren/deleteLeftBehindChildrenInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 查看留守儿童信息
export const leftBehindChildrenGetLeftBehindChildrenInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/leftBehindChildren/getLeftBehindChildrenInfo',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 获取留守儿童信息列表(留守儿童-对象管理)
export const leftBehindChildrenGetLeftBehindChildrenListApi = (data?: object) => {
    return request(
        {
            url: '/child/leftBehindChildren/getLeftBehindChildrenList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 获取留守儿童信息列表(留守儿童-监护监督)
export const leftBehindChildrenGetLeftGuardianshipSupervisionListApi = (data?: object) => {
    return request(
        {
            url: '/child/leftBehindChildren/getLeftGuardianshipSupervisionList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 留守儿童委托照护责任确认书pdf查看
export const leftBehindChildrenGetLiabilityPdfApi = (data?: object) => {
    return request(
        {
            url: '/child/leftBehindChildren/getLiabilityPdf',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 保存更新留守儿童信息
export const leftBehindChildrenSaveLeftBehindChildrenInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/leftBehindChildren/saveLeftBehindChildrenInfo',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 留守儿童委托照护责任确认书pdf新增修改
export const leftBehindChildrenSaveLiabilityPdfApi = (data?: object) => {
    return request(
        {
            url: '/child/leftBehindChildren/saveLiabilityPdf',
            method: 'post',
            data,
        },
        false,
        true
    );
};

// 困境儿童
// 困境儿童列表 过期
export const difficultyChildGetChildListApi = (data?: object) => {
    return request(
        {
            url: '/child/difficultyChild/getChildList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 困境儿童列表
export const childApplyGetDilemmaChildListApi = (data?: object) => {
    return request(
        {
            url: '/child/childApply/getDilemmaChildList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 查看困境儿童信息
export const difficultyChildGetChildDetailInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/difficultyChild/getChildDetailInfo',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 保存困境儿童信息
export const newChildSaveEavluateChildInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/newChild/saveEavluateChildInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 变更困境儿童信息
export const newChildChangeEavluateChildInfoApi = (data?: object) => {
    return request(
        {
            url: '/child/newChild/changeEavluateChildInfo',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 注销困境儿童信息
export const newChildCancelChildApi = (data?: object) => {
    return request(
        {
            url: '/child/newChild/cancelChild',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 困境儿童政策计算
export const difficultyChildCountChildTypeApi = (data?: object) => {
    return request(
        {
            url: '/child/difficultyChild/countChildType',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 困境儿童审核
export const childApplyChildSubmitApprovalApi = (data?: object) => {
    return request(
        {
            url: '/child/childApply/childSubmitApproval',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 困境儿童审批
export const childApplyChildSubmitCloseApi = (data?: object) => {
    return request(
        {
            url: '/child/childApply/childSubmitClose',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 工作人员走访
// 工作人员走访批次；一年两查；一月一访问列表
export const childTaskGetBatchListApi = (data?: object) => {
    return request(
        {
            url: '/child/childTask/getBatchList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 工作人员走访任务列表
export const childTaskGetRecordListApi = (data?: object) => {
    return request(
        {
            url: '/child/childTask/getRecordList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 项目管理
// 项目开发列表
export const childActivityListApi = (data?: object) => {
    return request(
        {
            url: '/child/childActivity/list',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 活动管理列表
export const childActivityItemListApi = (data?: object) => {
    return request(
        {
            url: '/child/childActivity/itemList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 工作管理
// 人员管理列表
export const childUserListApi = (data?: object) => {
    return request(
        {
            url: '/child/user/list',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 儿童数据同步
// 儿童数据同步列表
export const syncStChildGetListApi = (data?: object) => {
    return request(
        {
            url: '/child/syncStChild/getList',
            method: 'post',
            data,
        },
        false,
        true
    );
};
export const loginApi = (data?: object) => {
    return request(
        {
            url: '/child/syncStChild/login',
            method: 'post',
            data,
        },
        false,
        true
    );
};
export const getCaptchaApi = (data?: object) => {
    return request(
        {
            url: '/child/syncStChild/getCaptcha',
            method: 'post',
            data,
        },
        false,
        true
    );
};
// 身份证验证接口
export const idOrcApi = (data?: Object) => {
    return request(
        {
            // url: "/assistanceWeixin/idOrc",
            // url: "/business/api/baiduApi/idCard",
            url: '/api/api/baiduApi/idCard',
            method: 'post',
            data,
        },
        true,
        true
    );
};
export const fileUploadBase64ExApi = (data?: Object) => {
    return request(
        {
            url: '/business/api/file/fileUploadBase64Ex',
            method: 'post',
            data,
        },
        true,
        true
    );
};
//发送短信验证码接口
export const saveCemeteryReserveApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/onlinegenealogy/saveCemeteryReserve',
            method: 'post',
            data,
        },
        true,
        true
    );
};
//发送短信验证码接口
export const sendSmsApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/onlinegenealogy/sendSms',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 微信
// 第二步：通过code换取网页授权access_token
// appid：公众号的唯一标识 secret：公众号的appsecret code：填写第一步获取的code参数 grant_type：填写为authorization_code
export const weixinAccessTokenApi = (params: Object) => {
    return request(
        {
            // url: "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code",
            url: '/sns/oauth2/access_token',
            // url: '/sns/oauth2/access_token?appid=' + params.appid + '&secret=' + params.secret + '&code=' + params.code + '&grant_type=authorization_code',
            method: 'get',
            params,
        },
        true,
        true
    );
};
// 第三步：刷新access_token（如果需要）
// appid：公众号的唯一标识 grant_type：填写为refresh_token refresh_token：填写通过access_token获取到的refresh_token参数
export const weixinRefreshTokenApi = (params: Object) => {
    return request(
        {
            url: '/sns/oauth2/refresh_token',
            method: 'get',
            params,
        },
        true,
        true
    );
};
// 第四步：拉取用户信息(需scope为 snsapi_userinfo)
// appid：公众号的唯一标识 grant_type：填写为refresh_token refresh_token：填写通过access_token获取到的refresh_token参数
export const weixinUserinfoApi = (params: Object) => {
    return request(
        {
            url: '/sns/userinfo',
            method: 'get',
            params,
        },
        true,
        true
    );
};
